<?xml version="1.0" encoding="UTF-8"?>

<!-- Copyright 2007 XBRL International. All Rights Reserved. -->

<link:linkbase
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:generic="http://xbrl.org/2008/generic"
  xmlns:formula="http://xbrl.org/2008/formula"
  xmlns:instance="http://xbrl.org/2008/formula/instance"
  xmlns:variable="http://xbrl.org/2008/variable"
  xmlns:cf="http://xbrl.org/2008/filter/concept"
  xmlns:df="http://xbrl.org/2008/filter/dimension"
  xmlns:pf="http://xbrl.org/2008/filter/period"
  xmlns:uf="http://xbrl.org/2008/filter/unit"
  xmlns:ca="http://xbrl.org/2008/assertion/consistency"
  xmlns:label="http://xbrl.org/2008/label"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:test="http://abc.com/test1"

  xsi:schemaLocation="
  http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
  http://xbrl.org/2008/generic ../../core_schemas/generic-link.xsd
  http://xbrl.org/2008/formula ../../core_schemas/formula.xsd
  http://xbrl.org/2008/variable ../../core_schemas/variable.xsd
  http://xbrl.org/2008/assertion/consistency ../../core_schemas/consistency-assertion.xsd
  http://xbrl.org/2008/filter/concept ../../core_schemas/concept-filter.xsd
  http://xbrl.org/2008/filter/period ../../core_schemas/period-filter.xsd
  http://xbrl.org/2008/filter/unit ../../core_schemas/unit-filter.xsd
  http://xbrl.org/2008/filter/dimension ../../core_schemas/dimension-filter.xsd
  http://xbrl.org/2008/label ../../core_schemas/generic-label.xsd
  http://xbrl.org/2008/formula/instance formula-instance.xsd
  ">
  
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/element-label" xlink:href="../../core_schemas/generic-label.xsd#element-label" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-set" xlink:href="../../core_schemas/variable.xsd#variable-set" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-filter" xlink:href="../../core_schemas/variable.xsd#variable-filter" xlink:type="simple"/>
  <link:roleRef roleURI="http://www.xbrl.org/2008/role/link" xlink:href="../../core_schemas/generic-link.xsd#standard-link-role" xlink:type="simple"/>

  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/instance-variable" xlink:href="formula-instance.xsd#formula-scope" xlink:type="simple"/>

  <generic:link xlink:type="extended"
    xlink:role="http://www.xbrl.org/2008/role/link">

    <!-- (1) formula to produce test:e result fact item -->
    <formula:formula xlink:type="resource" xlink:label="formulaE" 
      value="$f + $g" 
      source="f"
      aspectModel="dimensional" implicitFiltering="true">
      <formula:decimals>0</formula:decimals>
      <formula:aspects>
        <formula:concept>
          <formula:qname>test:e</formula:qname>
        </formula:concept>
      </formula:aspects>
    </formula:formula>

    <!-- formulaE's result (1) is made visible to formulaC (2) -->
    <instance:formulaScopeArc xlink:type="arc" 
      xlink:arcrole="http://xbrl.org/arcrole/2008/formula-scope"
      name="e" 
      xlink:from="formulaE" xlink:to="formulaC" order="1.0"/>

    <!-- (2) formula produces a single test:c = $d + $e from (1) above -->
    <formula:formula xlink:type="resource" xlink:label="formulaC" 
      value="$d + $e" 
      source="d"
      aspectModel="dimensional" implicitFiltering="true">
      <formula:decimals>0</formula:decimals>
      <formula:aspects>
        <formula:concept>
          <formula:qname>test:c</formula:qname>
        </formula:concept>
      </formula:aspects>
    </formula:formula>

    <!-- formulaC's result (2), which includes the inherited in-scope
         variables from formulaE (1), both are made visible to formulaA (3) -->
    <instance:formulaScopeArc xlink:type="arc" 
      xlink:arcrole="http://xbrl.org/arcrole/2008/formula-scope"
      name="c" 
      xlink:from="formulaC" xlink:to="formulaA" order="1.0"/>

    <!-- (3) formula produces a single test:a = $b + $c + $e from (2) & (1) -->
    <!-- formula 1 produces a = b + c +d -->
    <formula:formula xlink:type="resource" xlink:label="formulaA" 
      value="$b + $c + $e"
      source="b"
      aspectModel="dimensional" implicitFiltering="true" >
      <formula:decimals>0</formula:decimals>
      <formula:aspects>
        <formula:concept>
          <formula:qname>test:a</formula:qname>
        </formula:concept>
      </formula:aspects>
    </formula:formula>


    <!--  Fact variables.  Note that no general variables are used in this formula. -->
    <variable:factVariable xlink:type="resource" xlink:label="variable_b"   bindAsSequence="false" />
    <variable:factVariable xlink:type="resource" xlink:label="variable_d"   bindAsSequence="false" />
    <variable:factVariable xlink:type="resource" xlink:label="variable_f"   bindAsSequence="false" />
    <variable:factVariable xlink:type="resource" xlink:label="variable_g"   bindAsSequence="false" />


    <!--  Concept filters for the fact variables -->
    <cf:conceptName xlink:type="resource" xlink:label="filter_b">
      <cf:concept>
        <cf:qname>test:b</cf:qname>
      </cf:concept>
    </cf:conceptName> 

    <cf:conceptName xlink:type="resource" xlink:label="filter_d">
      <cf:concept>
        <cf:qname>test:d</cf:qname>
      </cf:concept>
    </cf:conceptName> 

    <cf:conceptName xlink:type="resource" xlink:label="filter_f">
      <cf:concept>
        <cf:qname>test:f</cf:qname>
      </cf:concept>
    </cf:conceptName> 

    <cf:conceptName xlink:type="resource" xlink:label="filter_g">
      <cf:concept>
        <cf:qname>test:g</cf:qname>
      </cf:concept>
    </cf:conceptName> 

    <!--  Arc from formulaA to the variables it depends on -->
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formulaA" xlink:to="variable_b" order="1.0"
      name="b" />

    <!--  Arc from formulaC to the variables it depends on -->
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formulaC" xlink:to="variable_d" order="1.0"
      name="d" />

    <!--  Arc from formulaE to the variables it depends on -->
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formulaE" xlink:to="variable_f" order="1.0"
      name="f" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formulaE" xlink:to="variable_g" order="1.0"
      name="g" />


    <!--  Arcs from variables to their concept filters -->
    <variable:variableFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-filter" 
      complement="false" cover="true"
      xlink:from="variable_b" xlink:to="filter_b" order="1.0"/>
    <variable:variableFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-filter" 
      complement="false" cover="true"
      xlink:from="variable_d" xlink:to="filter_d" order="1.0"/>
    <variable:variableFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-filter" 
      complement="false" cover="true"
      xlink:from="variable_f" xlink:to="filter_f" order="1.0"/>
    <variable:variableFilterArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-filter" 
      complement="false" cover="true"
      xlink:from="variable_g" xlink:to="filter_g" order="1.0"/>
  </generic:link>

</link:linkbase>
